﻿using MaterialManagement.Domain;
using MediatR;
using Process.Domain;
using ProductionLine.API.Application.Command.Dispatch;
using ProductionLine.Domain.Car;
using ProductionLine.Domain.Dispatch;
using ProductionLine.Domain.Product;
using ProductionLine.Domain.ProductLine;
using ProductionLine.Domain.Site;
using ProductionLine.Domain.Team;
using ProductionLine.ErrorCode;
using ProductionLine.Extensions;
using ProductionLine.Infrastructure.Interface;

namespace ProductionLine.API.Application.Handler.Dispatch
{
    public class GetDispatchHandler : IRequestHandler<GetDispatchCommand, APIResult<List<TaskDispatchModel>>>
    {

        IBaseRepository<TaskDispatchModel> baseRepository;

        public GetDispatchHandler(IBaseRepository<TaskDispatchModel> baseRepository)
        {
            this.baseRepository = baseRepository;
        }

        public Task<APIResult<List<TaskDispatchModel>>> Handle(GetDispatchCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<TaskDispatchModel>> res= new APIResult<List<TaskDispatchModel>>();
           var list=baseRepository.GetAll().Where(c=>!c.IsDel);


           
            res.Code = APIEnum.Success;
            res.Data = list.ToList();
            res.Msg = "查询工单成功";
            return Task.FromResult(res);
        }
    }
}
